package com.cheifsteam.springframework.aop.framework;

import com.cheifsteam.springframework.aop.AdvisedSupport;

/**
 * @author qrx
 * @date 2025/8/6 14:09
 * @description: 代理工厂
 */
public class ProxyFactory {

    private AdvisedSupport advisedSupport;


    public ProxyFactory(AdvisedSupport advisedSupport) {
        this.advisedSupport = advisedSupport;
    }
    public Object getProxy() {
        return createAopProxy().getProxy();
    }

    private AopProxy createAopProxy() {
        if (advisedSupport.isProxyTargetClass()) {
            return new Cglib2AopProxy(advisedSupport);
        }

        return new JdkDynamicAopProxy(advisedSupport);
    }

}
